<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue.js基本概念</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <h1>Vue.js基本概念</h1>
    <h2>Watch属性：侦听变量的变化</h2>
    <div id="app">
        <p>{{msg}}</p>
        <p>{{slogan}}</p>
        <p v-show="login">今天进账：XXX 元。</p>
        <p v-if="location =='湖北'">2级响应</p>
        <p v-else-if="location =='吉林'">1级响应</p>
        <p v-else="location">4级响应</p>
    </div>
    <script>
        var dataFromOutside = new Date()
        var app = new Vue({
            el: '#app',
            data: {
                msg: '这是来自vue的数据',
                location: '甘肃'
            },
            watch: {
                msg: function (newVal, oldVal) {
                    console.log('新值为：', newVal)
                    console.log('旧值为：', oldVal)
                }
            },
            computed: {
                slogan: function () {
                    return this.msg + ' ，没有浪费的青春， ' + dataFromOutside
                },
                login: function () {
                    return false
                }
            }
        });
    </script>

</body>

</html>
